package com.sxbbc.plat.controller.jz;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.function.common.GetRest;
import com.function.common.RestResponse;
import com.sxbbc.common.basics.exceptions.ThrowJsonException;
import com.sxbbc.common.basics.files.RestUploadFileInfo;
import com.sxbbc.common.basics.files.UploadUtils;
import com.sxbbc.common.basics.utils.calculation.CalcuUtils;
import com.sxbbc.common.basics.utils.encrypts.pwd.Encode;
import com.sxbbc.common.basics.utils.regular.RpxUtils;
import com.sxbbc.common.basics.utils.statics.StaticUtils;
import com.sxbbc.common.core.entity.jz.*;
import com.sxbbc.common.core.enums.BusinessScopeEnums;
import com.sxbbc.common.core.enums.BusinessTypeEnums;
import com.sxbbc.common.core.enums.FromTypeEnums;
import com.sxbbc.common.core.service.*;
import com.sxbbc.common.core.utils.BasePage;
import com.sxbbc.common.core.utils.FileUtils;
import com.sxbbc.common.core.utils.MultipartFileToFile;
import com.sxbbc.plat.common.BusinessMapping;
import com.sxbbc.plat.common.UploadMapping;
import com.sxbbc.plat.service.BusinessService;
import com.sxbbc.plat.util.PlatSession;
import com.sxbbc.plat.util.SystemLog;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.*;

/**
 * 在平台的商家管理 控制层
 *
 * @author leehao
 * @date 2019-05-08 13:41
 */
@Controller
public class BusinessController {
    @Autowired
    private BusinessService businessService;
    @Autowired
    private BBusinessService bBusinessService;
    @Autowired
    private IBAccountService ibAccountService;
    @Autowired
    private IBLoginService ibLoginService;
    @Autowired
    private IAddressService addressService;
    @Autowired
    private IProcBrandInfoService brandInfoService;
    @Autowired
    private IIndustryService industryService;
    @Autowired
    private ISysUserService sysUserService;

    /**
     * 商家列表页面
     *
     * @param page     分页条件
     * @param business 查询条件
     * @return org.springframework.web.servlet.ModelAndView
     * @author leehao
     */
    @RequestMapping(value = BusinessMapping.SHOW_BUSINESS_LIST)
    public ModelAndView showBusinessList(BasePage<BBusiness> page, BBusiness business) {
        Page<BBusiness> pageInfo = bBusinessService.queryBusinessList(page, business);
        Address address = new Address();
        Integer pid = null;
        List<Address> proAddrList = null;
        List<Address> cityAddrList = null;
        List<Address> areaAddrList = null;

        address.setPid(null);
        proAddrList = addressService.queryAddressByParentId(address);
        if (business.getProId() != null) {
            pid = business.getProId();
            address.setPid(pid);
            cityAddrList = addressService.queryAddressByParentId(address);
        }
        if (business.getCityId() != null) {
            pid = business.getCityId();
            address.setPid(pid);
            areaAddrList = addressService.queryAddressByParentId(address);
        }


        ModelAndView view = new ModelAndView(BusinessMapping.SHOW_BUSINESS_LIST);
        view.addObject("proAddrList", proAddrList);
        view.addObject("cityAddrList", cityAddrList);
        view.addObject("areaAddrList", areaAddrList);
        view.addObject("pageInfo", pageInfo);
        view.addObject("business", business);
        return view;
    }

    /**
     * 新增商家页面
     *
     * @param request /
     * @return org.springframework.web.servlet.ModelAndView
     * @author leehao
     */
    @RequestMapping(value = BusinessMapping.SHOW_BUSINESS_ADD)
    public ModelAndView showAddBusiness(HttpServletRequest request) {
        // 商家类型
        List<BusinessTypeEnums> busList = BusinessTypeEnums.queryList();
        // 地址
        Address address = new Address();
        address.setPid(StaticUtils.ADDRESS_COUNTRY);
        List<Address> addressList = addressService.queryAddressByParentId(address);
        // 品牌
        List<ProcBrandInfo> brandList = brandInfoService.list(new QueryWrapper<>());
        // 经营范围
        List<BusinessScopeEnums> scopeList = BusinessScopeEnums.queryList();
        // 主行业
        QueryWrapper<Industry> wrapper = new QueryWrapper<>();
        wrapper.eq("status", StaticUtils.STATUS_YES);
        List<Industry> industryList = industryService.list(wrapper);
        ModelAndView view = new ModelAndView(BusinessMapping.SHOW_BUSINESS_ADD);
        view.addObject("busList", busList);
        view.addObject("addressList", addressList);
        view.addObject("brandList", brandList);
        view.addObject("scopeList", scopeList);
        view.addObject("industryList", industryList);
        return view;
    }

    /**
     * 编辑 新增商家页面
     *
     * @param request /
     * @param id      商家id
     * @return org.springframework.web.servlet.ModelAndView
     * @author leehao
     */
    @RequestMapping(value = BusinessMapping.SHOW_BUSINESS_EDIT)
    public ModelAndView showEditBusiness(HttpServletRequest request, Integer id) {
        BBusiness business = bBusinessService.getById(id);
        if (!StringUtils.isEmpty(business.getCoverUrl())) {
            JSONArray jsonArray = JSON.parseArray(business.getCoverUrl());
            StringBuffer coverUrl = new StringBuffer();
            for (int i = 0; i < jsonArray.size(); i++) {
                String str = "";
                JSONObject jsonObject = (JSONObject) JSONObject.toJSON(jsonArray.get(i));
                str = (String) jsonObject.get("url");
                coverUrl.append(str);
                if (i < jsonArray.size() - 1) {
                    coverUrl.append(",");
                }
            }
            business.setCoverUrl(coverUrl.toString());
        }
        // 商家类型
        List<BusinessTypeEnums> busList = BusinessTypeEnums.queryList();
        // 地址
        Address address = new Address();
        address.setPid(StaticUtils.ADDRESS_COUNTRY);
        // 省列表
        List<Address> proList = addressService.queryAddressByParentId(address);
        // 市列表
        List<Address> cityList = new ArrayList<>();
        // 区列表
        List<Address> areaList = new ArrayList<>();
        if (business.getCityId() != null) {
            address.setPid(business.getProId());
            cityList = addressService.queryAddressByParentId(address);
        }
        if (business.getAreaId() != null) {
            address.setPid(business.getCityId());
            areaList = addressService.queryAddressByParentId(address);
        }
        // 品牌
        List<ProcBrandInfo> brandList = brandInfoService.list(new QueryWrapper<>());
        // 经营范围
        List<BusinessScopeEnums> scopeList = BusinessScopeEnums.queryList();
        // 主行业
        QueryWrapper<Industry> wrapper = new QueryWrapper<>();
        wrapper.eq("status", StaticUtils.STATUS_YES);
        List<Industry> industryList = industryService.list(wrapper);
        // 子行业
        /*QueryWrapper<IndustryDetail> ew = new QueryWrapper<>();
        ew.eq("ind_id",business.getIndustryId());
        List<IndustryDetail> industryDetailList = industryDetailService.list(ew);*/
        ModelAndView view = new ModelAndView(BusinessMapping.SHOW_BUSINESS_EDIT);
        view.addObject("business", business);
        view.addObject("busList", busList);
        view.addObject("proList", proList);
        view.addObject("cityList", cityList);
        view.addObject("areaList", areaList);
        view.addObject("brandList", brandList);
        view.addObject("scopeList", scopeList);
        view.addObject("industryList", industryList);
        //view.addObject("industryDetailList",industryDetailList);
        return view;
    }

    /**
     * 平台新增商家
     *
     * @param request  /
     * @param business 商家对象
     * @return com.function.common.RestResponse
     * @author leehao
     */
    @RequestMapping(value = BusinessMapping.ADD_BUSINESS)
    @ResponseBody
    @SystemLog(methods = "平台新增商家", module = "平台-商家管理")
    public RestResponse addBusinessInPlat(HttpServletRequest request, BBusiness business) {
        RpxUtils regex = RpxUtils.getInstance();
        CalcuUtils calUtil = CalcuUtils.getInstance();
        //绑定已注册用户
        if (StringUtils.isBlank(business.getExistPhone())) {
            return GetRest.getFail("请输入绑定用户的手机号码");
        }
        if (!StringUtils.equals(regex.validPhone(business.getExistPhone()), "")) {
            return GetRest.getFail("联系电话格式有误：" + regex.validPhone(business.getExistPhone()));
        }
        String[] split = business.getWorkTime().split("~");
        if (split.length != 2 || !business.getWorkTime().contains(":")) {
            return GetRest.getFail("营业时间格式错误,请检查是否有 ~ 和两个 : 字符");
        }
        if (business.getOnOff() == null) {
            return GetRest.getFail("请选择店铺类型");
        }
        if (calUtil.isEquals(business.getOnOff(), BusinessScopeEnums.ONLINE.getId()) && calUtil.isEquals(business.getBType(), BusinessTypeEnums.SETTLED.getId())) {
            return GetRest.getFail("线上商家不能申请为入驻店铺类型");
        }
        //信息验证
        RestResponse result = null;
        if (calUtil.isEquals(business.getOnOff(), BusinessScopeEnums.ONLINE.getId())) {
            //线上商家信息验证
            result = checkBusinessForOnline(business);
            if (!result.isStatus()) {
                return result;
            }
            business.setStatus(StaticUtils.STATUS_SUCCESS);
        } else if (calUtil.isEquals(business.getOnOff(), BusinessScopeEnums.OFFLINE.getId())) {
            //线下商家信息验证
            result = checkBusinessForOffline(business);
            if (!result.isStatus()) {
                return result;
            }
            business.setOfflineStatus(StaticUtils.STATUS_SUCCESS);
        }
        business.setCreatetime(new Date());

        // 商家来源，设置为'平台添加'
        business.setFromType(FromTypeEnums.PLAT_ADD.getId());
        business.setEndTime(new Date());
        // 商家交易密码，默认设置为888888 md5加密
        business.setPayWord(Encode.md5Encode(StaticUtils.DEFAULT_PASSWORD));
        // 门头照
        if (StringUtils.isNotBlank(business.getUrls())) {
            JSONArray jsonArray = new JSONArray();
            String[] url = business.getUrls().split(",");
            for (String s : url) {
                JSONObject o = new JSONObject();
                o.put("url", s);
                jsonArray.add(o);
            }
            business.setCoverUrl(jsonArray.toString());
        }
        return bBusinessService.addBusiness(business);
    }

    /**
     * 平台编辑商家
     *
     * @param business 商家对象
     * @return com.function.common.RestResponse
     * @author leehao
     */
    @RequestMapping(value = BusinessMapping.EDIT_BUSINESS)
    @ResponseBody
    public RestResponse editBusinessInPlat(BBusiness business) {
        CalcuUtils calUtil = CalcuUtils.getInstance();
        if (calUtil.isEquals(business.getOnOff(), BusinessScopeEnums.ONLINE.getId()) && calUtil.isEquals(business.getBType(), BusinessTypeEnums.SETTLED.getId())) {
            return GetRest.getFail("线上商家不能申请为入驻店铺类型");
        }
        if (business.getId() == null) {
            return GetRest.getFail("获取商家信息失败");
        }
        BBusiness bBusiness = bBusinessService.getById(business.getId());
        if (bBusiness == null) {
            return GetRest.getFail("获取商家信息失败");
        }
        //原来类型
        Integer originalScope = bBusiness.getOnOff();
        //信息验证
        RestResponse result = null;
        //编辑时店铺范围与原来一致 不对店铺范围进行改变
        if (calUtil.isEquals(originalScope, business.getOnOff())) {
            if (calUtil.isEquals(originalScope, BusinessScopeEnums.ONLINE.getId())) {
                result = checkBusinessForOnline(business);
                if (!result.isStatus()) {
                    return result;
                }
            } else if (calUtil.isEquals(originalScope, BusinessScopeEnums.OFFLINE.getId())) {
                result = checkBusinessForOffline(business);
                if (!result.isStatus()) {
                    return result;
                }
            }
        } else {
            /* 编辑时店铺范围与原来不一致 原来的店铺范围取消 */
            if (calUtil.isEquals(business.getOnOff(), BusinessScopeEnums.ONLINE.getId())) {
                //变更为线上
                result = checkBusinessForOnline(business);
                if (!result.isStatus()) {
                    return result;
                }
                business.setOnOff(BusinessScopeEnums.ONLINE.getId());
                business.setStatus(StaticUtils.STATUS_SUCCESS);
                business.setOfflineStatus(StaticUtils.STATUS_NO);
                business.setNickName(StaticUtils.SPECIAL_STRING_FLAG);
            } else if (calUtil.isEquals(business.getOnOff(), BusinessScopeEnums.OFFLINE.getId())) {
                //变更为线下
                result = checkBusinessForOffline(business);
                if (!result.isStatus()) {
                    return result;
                }
                business.setOnOff(BusinessScopeEnums.OFFLINE.getId());
                business.setStatus(StaticUtils.STATUS_NO);
                business.setOfflineStatus(StaticUtils.STATUS_SUCCESS);
                business.setNickNameOn(StaticUtils.SPECIAL_STRING_FLAG);
            }
        }
        if (StringUtils.isNotBlank(business.getUrls())) {
            JSONArray jsonArray = new JSONArray();
            String[] urls = business.getUrls().split(",");
            for (String url : urls) {
                JSONObject o = new JSONObject();
                o.put("url", url);
                jsonArray.add(o);
            }
            business.setCoverUrl(jsonArray.toString());
        }
        business.setFromType(FromTypeEnums.PLAT_ADD.getId());
        return bBusinessService.editBusiness(business);
    }

    /**
     * 平台新增商家 门头照 多张
     *
     * @param file 图片对象
     * @return com.function.common.RestResponse
     * @author leehao
     */
    @RequestMapping(value = UploadMapping.UPLOAD_FILE)
    @ResponseBody
    public RestResponse uploadFiles(@RequestParam(name = "file") MultipartFile file) {
//        RestUploadFileInfo result = UploadUtils.getInstance().uploadFileQN(file);
        String urls = "";
//        if (result.isStatus()) {
//            urls = result.getData();
//        }
        try {
            File fe= MultipartFileToFile.multipartFileToFile(file);
            urls= FileUtils.up(fe);
        }catch (Exception e){
            return GetRest.getFail("上传图片失败");
        }
        return GetRest.getSuccess("成功", urls);
    }

    /**
     * 表单提交上传图片
     *
     * @param frontImg 证件正面
     * @param backImg  证件反面
     * @param busImg   营业执照
     * @param busLogo  logo
     * @return com.function.common.RestResponse
     * @author leehao
     */
    @RequestMapping(UploadMapping.UPLOAD_FILE_BATCH)
    @ResponseBody
    public RestResponse uploadImage(@RequestParam(name = "frontImg", required = false) MultipartFile frontImg,
                                    @RequestParam(name = "backImg", required = false) MultipartFile backImg,
                                    @RequestParam(name = "busImg", required = false) MultipartFile busImg,
                                    @RequestParam(name = "busLogo", required = false) MultipartFile busLogo,
                                    @RequestParam(name = "offlineLogo", required = false) MultipartFile offlineLogo,
                                    @RequestParam(name = "licen1", required = false) MultipartFile licen1,
                                    @RequestParam(name = "licen2", required = false) MultipartFile licen2) {
        // 资料照片上传
        UploadUtils upload = UploadUtils.getInstance();
        RestUploadFileInfo result = null;
        Map<String, String> map = new HashMap<String, String>();
        if (frontImg != null) {
            result = upload.uploadFileQN(frontImg);
            if (result.isStatus()) {
                map.put("front", result.getData());
            } else if (!result.isStatus() && result != null) {
                return GetRest.getFail("身份证正面照片上传失败");
            }
        }
        if (backImg != null) {
            result = upload.uploadFileQN(backImg);
            if (result.isStatus()) {
                map.put("back", result.getData());
            } else if (!result.isStatus() && result != null) {
                return GetRest.getFail("身份证反面照片上传失败");
            }
        }
        if (busImg != null) {
            result = upload.uploadFileQN(busImg);
            if (result.isStatus()) {
                map.put("bus", result.getData());
            } else if (!result.isStatus() && result != null) {
                return GetRest.getFail("营业执照照片上传失败");
            }
        }
        if (busLogo != null) {
            result = upload.uploadFileQN(busLogo);
            if (result.isStatus()) {
                map.put("logo", result.getData());
            } else if (!result.isStatus() && busLogo != null) {
                return GetRest.getFail("店铺头像上传失败");
            }
        }
        if (offlineLogo != null) {
            result = upload.uploadFileQN(offlineLogo);
            if (result.isStatus()) {
                map.put("offLogo", result.getData());
            } else if (!result.isStatus() && offlineLogo != null) {
                return GetRest.getFail("店铺头像上传失败");
            }
        }
        if (licen1 != null) {
            result = upload.uploadFileQN(licen1);
            if (result.isStatus()) {
                map.put("pic1", result.getData());
            } else if (!result.isStatus() && licen1 != null) {
                return GetRest.getFail("图片上传失败");
            }
        }
        if (licen2 != null) {
            result = upload.uploadFileQN(licen2);
            if (result.isStatus()) {
                map.put("pic2", result.getData());
            } else if (!result.isStatus() && licen2 != null) {
                return GetRest.getFail("图片上传失败");
            }
        }
        return GetRest.getSuccess("success", map);
    }

    /**
     * 1)平台审核商家通过/驳回
     * 2)平台处理店铺关店/开店
     *
     * @param business 都需ID，进行1操作时传入status及驳回理由
     *                 进行2操作时传入open的值
     * @return com.function.common.RestResponse
     * @author leehao
     */
    @RequestMapping(value = BusinessMapping.HANDLE_BUSINESS_APPLY_STATUS)
    @ResponseBody
    @SystemLog(methods = "平台审核商家状态", module = "平台-商家管理")
    public RestResponse businessApplyStatus(BBusiness business) {
        // 如果是处理店铺的审核，更新审核时间
        if (business.getStatus() != null || business.getOfflineStatus() != null) {
            business.setEndTime(new Date());
        }
        businessService.handleBusinessApplyStatus(business);
        return GetRest.getSuccess("处理成功");
    }

    /**
     * 设置消费者权益
     *
     * @return com.function.common.RestResponse
     * @author leehao
     */
    @RequestMapping(value = BusinessMapping.HANDLE_SET_GUARANTEE)
    @ResponseBody
    public RestResponse handleSetGuarantee(BBusiness business) {
        boolean save = bBusinessService.updateById(business);
        if (!save) {
            throw new ThrowJsonException("设置消费者保证权益失败");
        }
        return GetRest.getSuccess("操作成功");
    }

    /**
     * 平台重置商家密码
     *
     * @param id   商家id
     * @param type 1重置登录密码/2重置交易密码
     * @return com.function.common.RestResponse
     * @author leehao
     */
    @RequestMapping(value = BusinessMapping.HANDLE_RESET_BUSINESS_PASSWORD)
    @ResponseBody
    @SystemLog(methods = "重置商家登录/交易密码", module = "商家管理")
    public RestResponse handleResetBusinessPassword(Integer id, Integer type) {
        return bBusinessService.handleResetBusinessPassword(id, type);
    }

    /**
     * 平台删除商家信息
     * 敏感操作，拿到对应操作员的信息
     *
     * @param request 获取管理员信息
     * @param id      商家ID
     * @return com.function.common.RestResponse
     * @author leehao
     */
    @RequestMapping(value = BusinessMapping.DELETE_BUSINESS)
    @ResponseBody
    @SystemLog(methods = "删除商家信息", module = "商家管理")
    public RestResponse deleteBusinessById(HttpServletRequest request, Integer id) {
        //敏感操作，拿到管理员信息后才可操作
        Integer userId = PlatSession.getUserId(request);
        if (userId == null) {
            return GetRest.getFail("获取管理员信息失败");
        }
        SysUser user = sysUserService.getById(userId);
        if (user == null) {
            return GetRest.getFail("该管理员不存在");
        }
        //自营店铺禁止删除
        BBusiness business = bBusinessService.getById(id);
        if (CalcuUtils.getInstance().isEquals(business.getBType(), BusinessTypeEnums.OWN_BUSINESS.getId())) {
            return GetRest.getFail("自营店铺不允许删除");
        }
        //删除商家账户
        boolean save = ibAccountService.removeByBid(id);
        if (!save) {
            throw new ThrowJsonException("删除商家账户信息失败");
        }
        //删除商家登录对象
        save = ibLoginService.removeByBid(id);
        if (!save) {
            throw new ThrowJsonException("删除商家登录信息失败");
        }
        //删除商家信息
        save = bBusinessService.removeById(id);
        if (!save) {
            throw new ThrowJsonException("删除商家信息失败");
        }
        return GetRest.getSuccess("删除成功");
    }

    /* -------------------- 方法验证区域 -------------------- */

    /**
     * 验证线上信息
     *
     * @param business 验证信息
     * @return com.function.common.RestResponse
     * @author leehao
     */
    private RestResponse checkBusinessForOnline(BBusiness business) {
        if (StringUtils.isBlank(business.getNickNameOn())) {
            return GetRest.getFail("请输入线上店铺名");
        }
        if (StringUtils.isBlank(business.getLogo())) {
            return GetRest.getFail("请上传线上Logo");
        }
        RestResponse result = checkBusinessForPublic(business);
        if (!result.isStatus()) {
            return result;
        }
        return GetRest.getSuccess("校验成功");
    }

    /**
     * 验证线下信息
     *
     * @param business 验证信息
     * @return com.function.common.RestResponse
     * @author leehao
     */
    private RestResponse checkBusinessForOffline(BBusiness business) {
        if (StringUtils.isBlank(business.getNickName())) {
            return GetRest.getFail("请输入线下店铺名");
        }
        if (StringUtils.isBlank(business.getLinkPhone())) {
            return GetRest.getFail("请输入线下店铺联系电话");
        }
        if (StringUtils.isBlank(business.getHeadUrl())) {
            return GetRest.getFail("请上传线下店铺头像");
        }
        if (StringUtils.isBlank(business.getUrls())) {
            return GetRest.getFail("请上传线下店铺门头照");
        }
        RestResponse result = checkBusinessForPublic(business);
        if (!result.isStatus()) {
            return result;
        }
        return GetRest.getSuccess("校验成功");
    }

    /**
     * 验证所有信息
     *
     * @param business 商家信息
     * @return com.function.common.RestResponse
     * @author leehao
     */
    private RestResponse checkBusinessForAll(BBusiness business) {
        if (StringUtils.isBlank(business.getNickNameOn())) {
            return GetRest.getFail("请输入线上店铺名");
        }
        if (StringUtils.isBlank(business.getLogo())) {
            return GetRest.getFail("请上传线上Logo");
        }
        if (StringUtils.isBlank(business.getNickName())) {
            return GetRest.getFail("请输入线下店铺名");
        }
        if (StringUtils.isBlank(business.getLinkPhone())) {
            return GetRest.getFail("请输入线下店铺联系电话");
        }
        if (StringUtils.isBlank(business.getHeadUrl())) {
            return GetRest.getFail("请上传线下店铺头像");
        }
        if (StringUtils.isBlank(business.getUrls())) {
            return GetRest.getFail("请上传线下店铺门头照");
        }
        RestResponse result = checkBusinessForPublic(business);
        if (!result.isStatus()) {
            return result;
        }
        return GetRest.getSuccess("校验成功");
    }

    /**
     * 验证公共信息
     *
     * @param business 验证信息
     * @return com.function.common.RestResponse
     * @author leehao
     */
    private RestResponse checkBusinessForPublic(BBusiness business) {
        if (StringUtils.equals(business.getNickName(), StaticUtils.SPECIAL_STRING_FLAG)) {
            return GetRest.getFail("非法名称");
        }
        if (StringUtils.equals(business.getNickNameOn(), StaticUtils.SPECIAL_STRING_FLAG)) {
            return GetRest.getFail("非法名称");
        }
//        if (StringUtils.isBlank(business.getCompanyName())) {
//            return GetRest.getFail("请输入企业名称");
//        }
        if (StringUtils.isBlank(business.getRealName())) {
            return GetRest.getFail("请输入法人姓名");
        }
        if (StringUtils.isBlank(business.getPhone())) {
            return GetRest.getFail("请输入联系电话");
        }
        if (StringUtils.isBlank(business.getLicenseCode())) {
            return GetRest.getFail("请输入营业执照号码");
        }
        if (business.getLicenseCode().length() < 15) {
            return GetRest.getFail("请输入正确的营业执照号（15位）");
        }
        if (business.getIndustryId() == null) {
            return GetRest.getFail("请选择行业");
        }
        if (business.getProId() == null) {
            return GetRest.getFail("请选择省份");
        }
        if (business.getCityId() == null) {
            return GetRest.getFail("请选择城市");
        }
        if (business.getAreaId() == null) {
            return GetRest.getFail("请选择区县");
        }
        if (StringUtils.isBlank(business.getCardFileFront())) {
            return GetRest.getFail("请上传法人证件照（国徽面）");
        }
        if (StringUtils.isBlank(business.getCardFileBack())) {
            return GetRest.getFail("请上传法人证件照（相片面）");
        }
        if (StringUtils.isBlank(business.getBusLicense())) {
            return GetRest.getFail("请上传营业执照");
        }
        return GetRest.getSuccess("校验成功");
    }
}
